package top.xiaodaiyu.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import top.xiaodaiyu.model.User;
import top.xiaodaiyu.service.user.UserService;

@Slf4j
@RestController(value = "dd")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(value = "/dell", method = RequestMethod.POST)
    public String addUser(User user) {
        log.info("user:==============" + user);
        userService.addUser(user);
        return "ok";
    }

    @RequestMapping(value = "/find")
    public Object findUser(@RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", required = false, defaultValue = "2") int pageSize) {
        log.info("pageNum:==============" + pageNum);
        return  userService.findAllUser(pageNum,pageSize);

    }
}
